// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IRepository.cs" company="emrecoskun.net">
//   ecblog.codeplex.com - emrecoskun.net
// </copyright>
// <summary>
//   The repository interface.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace EcBlog.Data.Base
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Linq.Expressions;

    /// <summary>
    /// The repository interface.
    /// </summary>
    /// <typeparam name="TEntity">The type of the entity.</typeparam>
    public interface IRepository<TEntity>
        where TEntity : class
    {
        /// <summary>
        /// Creates the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void Create(TEntity entity);
        
        /// <summary>
        /// Deletes the specified id.
        /// </summary>
        /// <param name="id">The id.</param>
        void Delete(object id);
        
        /// <summary>
        /// Deletes the specified entity to delete.
        /// </summary>
        /// <param name="entityToDelete">The entity to delete.</param>
        void Delete(TEntity entityToDelete);

        /// <summary>
        /// Gets the entity query specified include properties.
        /// </summary>
        /// <param name="includeProperties">The include properties.</param>
        /// <returns>The entity query</returns>
        IQueryable<TEntity> Get(string includeProperties = "");

        /// <summary>
        /// Gets the entity query specified include properties.
        /// </summary>
        /// <param name="includeProperties">The include properties.</param>
        /// <returns>The entity query</returns>
        IQueryable<TEntity> Get(params Expression<Func<TEntity, object>>[] includeProperties);
        
        /// <summary>
        /// Gets the entity by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns>The entity</returns>
        TEntity GetById(object id);
        
        /// <summary>
        /// Gets the entity list with raw SQL.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>The entity list</returns>
        IEnumerable<TEntity> GetWithRawSql(string query, params object[] parameters);
        
        /// <summary>
        /// Updates the specified entity to update.
        /// </summary>
        /// <param name="entityToUpdate">The entity to update.</param>
        void Update(TEntity entityToUpdate);
    }
}